geom_sgeom_sgeom_s are the building blocks of other geom_s
geom_smooth() adds a line based on a formula and some kind of regressiongeom_rect() adds a box made of linesaes()geom_s) on a plotgeom_s:
x, y, color, size, alpha, groupgeom-specific
xmin, xmax, xend, yend, linetype, fill, shapeLook to the ggplot function reference when in doubt.
geom_ribbon()x and y
Bee pollen removal experiment1
tibble [47 × 3] (S3: tbl_df/tbl/data.frame)
$ Prop_removed: num [1:47] 0.07 0.1 0.11 0.12 0.15 0.19 0.28 0.31 0.3 0.34 ...
$ Duration : int [1:47] 2 5 7 11 12 11 9 9 16 17 ...
$ Bee_type : chr [1:47] "Queen" "Queen" "Queen" "Queen" ...
What kind of plot would best represent these data?
x and what is y?By convention:
y is the variable of primary interestx is what predicts y or the grouping of interestGenerate some data to work with
# A tibble: 6 × 5
x1 y x2 x3 x4
<dbl> <dbl> <int> <chr> <dbl>
1 0.0105 0.436 4 B 0.150
2 0.114 -2.35 2 C 0.917
3 0.223 1.04 3 D 0.912
4 0.398 0.370 2 D 0.168
5 0.666 0.871 2 D 0.608
6 0.671 1.83 2 C 0.353
x2x2x3x3factor(x2)factor(x2)factor(x4)factor(x4)size aestheticsize aestheticUnset size = 5 inside geom_point()
Error in scale_f():
! A continuous variable can not be mapped to shape
Most often used for bars, including histograms:
We make this mistake every time:
Can also fill point shapes (not all pch can be filled):
alpha encodes transparency from 0 (transparent) to 1 (opaque)
geom_Compare:
...aes(x = x, y = y, color = x3, size = x4))
+ geom_point()
and
...aes(x = x, y = y))
+ geom_point(color = "darkred", size = 10)